# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=mujs
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.6
pkgrel=1
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: mujs'
)
msys2_repository_url='https://cgit.ghostscript.com/cgi-bin/cgit.cgi/mujs.git/'
url="http://mujs.com/"
msys2_references=(
  "cpe: cpe:/a:artifex:mujs"
)
license=('spdx:ISC')
pkgdesc='A lightweight Javascript interpreter designed for embedding in other software (mingw-w64)'
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-readline")
source=("https://mujs.com/downloads/${_realname}-${pkgver}.tar.gz"
        "001-makefile-fix.patch")
sha256sums=('7cf3a5e622cff41903efff0334518fc94af063256752c38ba4618a5191e44f18'
            'f4020f8a0f3b5d3bcfcb27d5ed9df8b8bba631f60deb2e35e2426ef74e9cc545')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ../001-makefile-fix.patch
}

build() {
  cd ${_realname}-${pkgver}
  make prefix=${MINGW_PREFIX} release
}

package() {
  cd ${_realname}-${pkgver}
  make DESTDIR="${pkgdir}" prefix=${MINGW_PREFIX} install

  install -Dm644 COPYING $pkgdir${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
  install -Dm644 README $pkgdir${MINGW_PREFIX}/share/doc/${_realname}/README
  cd docs/; for i in *; do
    install -Dm644 $i "${pkgdir}"${MINGW_PREFIX}/share/doc/${_realname}/$i
  done
}
